﻿using System.Configuration;
using System.ServiceModel.Channels;
using System.ServiceModel.Description;
using System.ServiceModel.Dispatcher;

namespace BookTheBook.Amazon
{
    internal class AmazonSigningEndpointBehavior : IEndpointBehavior
    {
        private readonly string _accessKeyId = ConfigurationManager.AppSettings["AWSAccessKeyId"];
        private readonly string _secretKeyId = ConfigurationManager.AppSettings["AWSASecretKeyId"];

        public void ApplyClientBehavior(ServiceEndpoint endpoint, ClientRuntime clientRuntime)
        {
            clientRuntime.MessageInspectors.Add(new AmazonSigningMessageInspector(_accessKeyId, _secretKeyId));
        }

        public void Validate(ServiceEndpoint endpoint)
        {
            return;
        }

        public void AddBindingParameters(ServiceEndpoint endpoint, BindingParameterCollection bindingParameters)
        {
            return;
        }

        public void ApplyDispatchBehavior(ServiceEndpoint endpoint, EndpointDispatcher endpointDispatcher)
        {
            return;
        }
    }
}